#include("common.html")
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>商城</title>
    
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <link rel="stylesheet" type="text/css" href="#(tpath)/static/css/vant.css">
    <link rel="stylesheet" type="text/css" href="#(tpath)/static/css/filter.css">
	<link rel="stylesheet" type="text/css" href="#(tpath)/static/toast/animate.css">
	<link rel="stylesheet" type="text/css" href="#(tpath)/static/toast/toast.css">
    <script type="text/javascript" src="#(tpath)/static/js/jquery.js"></script>
    <script type="text/javascript" src="#(tpath)/static/toast/toast.js"></script>
  </head>
  
  <body>
    <style type="text/css">@media only screen and (min-width: 320px){ html { font-size: 62.5% !important; } } @media only screen and (min-width: 640px){ html { font-size: 125% !important; } } @media only screen and (min-width: 750px){ html { font-size: 150% !important; } } @media only screen and (min-width: 1242px){ html { font-size: 187.5% !important; } }</style>
    <!-- 样式 -->
    <style>.container { background: #f8f8f8; overflow: hidden; height: 100%; box-sizing: border-box; font-size: 14px; color: #666; position: relative; } .van-cell-group { background-color: #fff; } [class*=van-hairline]::after{ border: none; } .van-cell { padding: 20px 15px; } .van-field .van-cell__title{max-width: 75px;} .submitBox{margin:20px 0px;} .van-radio-group{height:40px} .van-radio { float: left; margin-right: 10px; color: #666; height: 40px; } .van-radio__label{ font-size:12px; margin-left: 5px; } .back-bt{ margin-top: 10px; } #errorTip{height: 22px;} .copyright-content{ position: fixed; bottom: 30px; width: 100%; text-align: center; font-size: 12px; color: #999; }</style>
    <!-- 内容 -->
    <div id="reg" class="container">
      <div class="small_block_title">
        <h1>绑定手机</h1></div>
      <div class="small_block_content">
      	<input type="hidden" id="qrcode" value="#(qrcode)">
        <div class="van-radio-group">
          <div class="van-radio">
            <span class="van-radio__input">
              <input type="radio" class="van-radio__control" value="cn">
              <i class="van-icon van-icon-checked">
                <!---->
                <!----></i>
            </span>
            <span class="van-radio__label">中国(+86)</span></div>
            
          <!-- <div class="van-radio">
            <span class="van-radio__input">
              <input type="radio" class="van-radio__control" value="au">
              <i class="van-icon van-icon-circle">
               
               </i>
            </span>
            <span class="van-radio__label">澳大利亚(+61)</span></div>
            
          <div class="van-radio">
            <span class="van-radio__input">
              <input type="radio" class="van-radio__control" value="nz">
              <i class="van-icon van-icon-circle">
               
               </i>
            </span>
            <span class="van-radio__label">新西兰(+64)</span></div> -->
            
        </div>
        <!---->
        <div class="van-cell-group van-hairline--top-bottom">
          <div class="van-cell van-cell--center van-cell--required van-field">
            <!---->
            <div class="van-cell__title">
              <span>手机号</span>
              <!----></div>
            <div class="van-cell__value">
              <div class="van-field__body">
                <input type="text" placeholder="建议使用常用手机" class="van-field__control" id="username">
                <!---->
                <!-- <div class="van-field__icon">
                  <i class="van-icon van-icon-question-o">
                   
                   </i>
                </div> -->
                <!----></div>
              <!----></div>
            <!----></div>
          <div class="van-cell van-cell--center van-cell--required van-field">
          <div class="van-cell__title">
            <span>验证码</span></div>
          <div class="van-cell__value">
            <div class="van-field__body">
              <input type="text" placeholder="输入图形验证码" class="van-field__control" id="captcha">
                <img width="80" src="#(base)/common/captcha/image" onclick="this.src='#(base)/common/captcha/image?'+Math.round(Math.random()*10);" class="captcha"></div>
          </div>
        </div>
        <div class="van-cell-group van-hairline--top-bottom">
          <div class="van-cell van-cell--center van-field">
            <!---->
            <div class="van-cell__title">
              <span>短信验证码</span>
              <!----></div>
            <div class="van-cell__value">
              <div class="van-field__body">
                <input type="text" placeholder="请输入短信验证码" class="van-field__control" id="code">
                <!---->
                <!---->
                <div class="van-field__button">
                  <button class="van-button van-button--primary van-button--small" id="sendCaptchaBtn" onclick="getVerify()">
                    <span class="van-button__text" id="getCode">发送验证码</span></button>
                </div>
              </div>
              <!----></div>
            <!----></div>
        </div>
        </div>
        <div class="submitBox">
          <button class="submit van-button van-button--danger van-button--large" id="bindBtn">
            <span class="van-button__text">确定</span></button>
        </div>
      </div>
    <!-- 底部内容-->
    <style>#mini_footer { /* position: absolute; */ text-align: center; width: 100%; font-size: 12px; color: #ccc; bottom: 10px; background: #f8f8f8; height: 20px; line-height: 20px; z-index: 999; }</style>
    <!-- <div id="mini_footer">@2016-2023 JRECMS All Rights Reserved</div> --></body>

</html>
<script type="text/javascript">
var c=60;
var t;
var issend = false;
var returl = '';
function timedCount(){
    $('#getCode').html(c+"s");
    c=c-1;
    t=setTimeout("timedCount()",1000);
    if(c==0){
        stopCount();
    }
}

function stopCount(){
    clearTimeout(t);
    $('#getCode').html('发送验证码');
    issend = false;
    c=60;
}

function getVerify(){
    if(issend && c > 0){
        return;
    }
    var captcha = $("#captcha").val();
	if(captcha==""){
		showMessage('请输入验证码！',true);
		return false;
	}
	var username = $("#username").val();
	if(username==""){
		showMessage('请输入手机号！',true);
		return false;
	}
	
	$.ajax({
        url: "#(base)/common/sms/sendRegister",
        type: "post",
        data: {"mobile":username,"captcha":captcha},
        dataType: "json",
        success: function(res){
        	if(res.type=="success"){
       			
       		}else{
       			showMessage(res.msg,true);
       		}
        },
        error: function(res){
        }
    });
    issend = true;
    timedCount();
}


$("#bindBtn").on("click",function(){
	var code = $("#code").val();
	if(code==""){
		showMessage('请输入短信验证码！',true);
		return false;
	}
	var username = $("#username").val();
	$.ajax({
        url: "#(base)/member/bind/saveBind",
        type: "post",
        data: {"username":username,"code":code},
        dataType: "json",
        success: function(res){
        	if(res.type=="success"){
        		showMessage("绑定成功",true);
        		setTimeout(function(){ location.href="#(base)/member/account"; }, 1500);
       		}else{
       			showMessage(res.msg,true);
       		}
        },
        error: function(res){
        }
    });
});
</script>